package com.ruoyi.web.controller.seal;

import java.util.List;

import com.ruoyi.common.constant.Constants;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.domain.entity.SealInfo;
import com.ruoyi.system.service.ISealInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 印章列表Controller
 *
 * @author ess
 * @date 2021-10-25
 */
@RestController
@RequestMapping("/seal/info")
public class SealInfoController extends BaseController
{
    @Autowired
    private ISealInfoService sealInfoService;

    /**
     * 查询印章列表列表
     */
    @PreAuthorize("@ss.hasPermi('seal:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(SealInfo sealInfo)
    {
        startPage();
        List<SealInfo> list = sealInfoService.selectSealInfoListScreenHw(sealInfo);
        return getDataTable(list);
    }

    /**
     * 查询印章列表列表
     */
    @PreAuthorize("@ss.hasPermi('seal:info:list')")
    @GetMapping("/listSeal")
    public TableDataInfo listSeal(SealInfo sealInfo)
    {
        startPage();
        List<SealInfo> list = sealInfoService.selectSealInfoListScreenSeal(sealInfo);
        return getDataTable(list);
    }

    /**
     * 导出印章列表列表
     */
    @PreAuthorize("@ss.hasPermi('seal:info:export')")
    @Log(title = "印章列表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SealInfo sealInfo)
    {
        List<SealInfo> list = sealInfoService.selectSealInfoList(sealInfo);
        ExcelUtil<SealInfo> util = new ExcelUtil<SealInfo>(SealInfo.class);
        return util.exportExcel(list, "印章列表数据");
    }

    /**
     * 获取印章列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('seal:info:query')")
    @GetMapping(value = "/{sealInfoId}")
    public AjaxResult getInfo(@PathVariable("sealInfoId") String sealInfoId)
    {
        return AjaxResult.success(sealInfoService.selectSealInfoBySealInfoId(sealInfoId));
    }

    /**
     * 新增印章列表
     */
    @PreAuthorize("@ss.hasPermi('seal:info:add')")
    @Log(title = "印章列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SealInfo sealInfo)
    {
        return toAjax(sealInfoService.insertSealInfo(sealInfo));
    }

    /**
     * 修改印章列表
     */
    @PreAuthorize("@ss.hasPermi('seal:info:edit')")
    @Log(title = "印章列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SealInfo sealInfo)
    {
        return toAjax(sealInfoService.updateSealInfo(sealInfo));
    }

    /**
     * 删除印章列表
     */
    @PreAuthorize("@ss.hasPermi('seal:info:remove')")
    @Log(title = "印章列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sealInfoIds}")
    public AjaxResult remove(@PathVariable String[] sealInfoIds)
    {
        return toAjax(sealInfoService.deleteSealInfoBySealInfoIds(sealInfoIds));
    }
}
